package com.tengju.support.domain.model.rule;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Map;

@Data
@AllArgsConstructor
@NoArgsConstructor
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "@Clazz")
public class UpgradeCenterAction implements Action{

    private Integer targetIndex;

    private static final String TARGET_INDEX_FIELD_NAME = "targetIndex";

    @JsonProperty(value = "@Clazz")
    String getClazz() {
        return this.getClass().getName();
    };

    public UpgradeCenterAction(Map<String,String> map) {
        String targetIndex = map.get(TARGET_INDEX_FIELD_NAME);
        this.targetIndex = Integer.parseInt(targetIndex);
    }

    @Override
    public Object execute(MetaInfo metaInfo) {
        return targetIndex;
    }
}
